<template>
	<view>
		<view class="tabsBox">
			<view class="tabs-1" v-if="type == 1">
				<view :class="index == tabsIndex ? 'item-active' : 'item'" v-for="(item, index) in list" :key="index" @click="tabClick(index)">
					{{ item }}
				</view>
			</view>
			<view class="tabs-2" v-if="type == 2">
				<view :class="index == tabsIndex ? 'item-active' : 'item'" v-for="(item, index) in list" :key="index" @click="tabClick(index)">
					<view class="name">{{ item }}</view>
					<view style="width: 100%; box-sizing: border-box; padding: 0 10%"><view class="line"></view></view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	props: {
		//根据type显示不同样式
		type: {
			type: [String, Number],
			default: 1
		},
		list: {
			type: Array,
			default: []
		},

		i: {
			type: [String, Number],
			default: 0
		}
	},

	watch: {
		i(newValue) {
			this.tabIndex = newValue;
		}
	},
	data() {
		return {
			tabsIndex: 0
		};
	},

	mounted() {},

	methods: {
		/**
		 *
		 */
		tabClick(index) {
			this.tabsIndex = index;

			this.$emit('change', index);
		}
	}
};
</script>
<style lang="scss" scoped>
.tabsBox {
	.tabs-1 {
		width: 100%;
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;

		.item {
			box-sizing: border-box;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 10rpx;
			border-style: solid;
			border-width: 1rpx;
			border-color: $uni-color-main;
			padding: 0 12rpx;
			height: 50rpx;
			font-size: 28rpx;
			color: $uni-color-main;
		}

		.item-active {
			box-sizing: border-box;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 10rpx;
			background: $uni-color-main;
			padding: 0 12rpx;
			height: 50rpx;
			font-size: 28rpx;

			color: #fff;
		}
	}

	.tabs-2 {
		// position: fixed;
		// top: 0;
		// z-index: 1000;
		width: 100%;
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;

		.item {
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			height: 50rpx;

			.name {
				font-size: 28rpx;
				//color: $uni-text-aux-color;
			}

			.line {
				margin-top: 4rpx;
				box-sizing: border-box;
				padding: 0 10rpx;
				width: 100%;
				height: 4rpx;
			}
		}

		.item-active {
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			transform: scale(1.1);

			height: 50rpx;

			.name {
				font-size: 29rpx;
				color: $uni-color-main;
			}

			.line {
				margin-top: 4rpx;
				box-sizing: border-box;
				padding: 0 10rpx;
				width: 100%;
				height: 4rpx;
				border-radius: 2rpx;
				background-color: $uni-color-main;
			}
		}
	}
}
</style>
